﻿using Hrm.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;

namespace Hrm.Web
{
    public class ErrorAttribute : HandleErrorAttribute
    {

        public override void OnException(ExceptionContext filterContext)
        {
            GlobalQueue.LogQueue.Enqueue(new Log()
            {
                Origin = filterContext.Exception.Source,
                Level = (int)EnumLogLevel.Error,
                Message = filterContext.Exception.Message,
                StackTrade = filterContext.Exception.StackTrace,
                CreateDatetime=DateTime.Now,
                CreateUserCode=filterContext.HttpContext.User.Identity.GetUserId()
            });
            filterContext.HttpContext.Response.Redirect("~/Home/Page500");
            base.OnException(filterContext);
        }
    }
}
